<?php
  // Classe definissant une exception de base de donnees
  //Auteur : Sebastian Mosser
  
class DatabaseException extends Exception {
	
	private $_query;
	private $_ans;
	
	public function __construct($query) {
		$this->_query = $query;
		$this->_ans = mysql_error();
		parent::__construct("Database Error !!",0);
	}
	
	function __toString() {
		return $this->_toString();
	}
	
	function _toString() {
		$res  = "<p><span class=\"error\">An exception occured ... bad guy ! <span></p>\n";
		$res .= "<h2>Message </h2>\n" ;
		$res .= "<p><span class=\"error\">". $this->message ."</span></p>\n" ;
		$res .= "<h2>Initial Query </h2>\n";
		$res .= "<p><code>" . nl2br($this->_query) . "</code></p>\n";
		$res .= "<h2>Server answer : </h2>\n"; 
		$res .= "<p><span class=\"error\">" . nl2br($this->_ans)  . "</span></p>\n";
		$res .= "<h2>Stack contents </h2>\n";
		$res .= "<p><code>".nl2br($this->getTraceAsString())."</code></p>\n";
		return $res;
		
	}


}


?>